package com.weds.edpf.core .web;

import com.alibaba.fastjson.JSONObject;
import org.springframework.web.bind.annotation.*;
import org.springframework.beans.factory.annotation.Autowired;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.Api;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;

import java.util.ArrayList;
import java.util.List;
import java.util.Date;
import javax.validation.Valid;

import com.weds.core.base.BaseController;
import com.weds.core.annotation.Logs;
import com.weds.core.resp.JsonResult;
import com.weds.core.base.BaseCommPager;
import com.weds.core.base.BasePageSearch;


import com.weds.edpf.core.entity .XfAcTimeEntity;
import com.weds.edpf.core.service .XfAcTimeService;

/**
 * @Author sxm
 * @Description XfAcTime管理
 * @Date 2020-06-11
 */
@RestController
@RequestMapping(value="/xfAcTime")
@Api(value = "XfAcTime管理", description = "XfAcTime管理")
public class XfAcTimeController extends BaseController{
	@Autowired
	private XfAcTimeService xfAcTimeService;

    
	private Logger log = LogManager.getLogger();

    @Logs
	@ApiOperation(value = "新增XfAcTime信息", notes = "新增XfAcTime信息")
	@RequestMapping(value = "/insert", method = RequestMethod.PUT)
	public JsonResult<Object> insert(@RequestBody @Valid XfAcTimeEntity record) {
        				xfAcTimeService.insertSelective(record);
		return succMsg();
	}

	@Logs
	@ApiOperation(value = "更新XfAcTime信息", notes = "更新XfAcTime信息")
	@RequestMapping(value = "/updateByPrimaryKey", method = RequestMethod.POST)
	public JsonResult<Object> updateByPrimaryKey(@RequestBody @Valid XfAcTimeEntity record) {
        		xfAcTimeService.updateByPrimaryKeySelective(record);
		return succMsg();
	}

		@Logs
	@ApiOperation(value = "查询XfAcTime清单", notes = "查询XfAcTime清单")
	@RequestMapping(value = "/selectListPageByEntity", method = RequestMethod.POST)
	public JsonResult<BaseCommPager<XfAcTimeEntity>> selectListPageByEntity(@RequestBody BasePageSearch<XfAcTimeEntity> record) {
		setPageHelper(record);
		XfAcTimeEntity entity = record.getSearch();
        if (entity == null) {
        	entity = new XfAcTimeEntity();
        }
                List<XfAcTimeEntity> list = xfAcTimeService.selectListByEntity(entity);
        		return succMsgData(new BaseCommPager<XfAcTimeEntity>(list));
	}

    @Logs
    @ApiOperation(value = "查询XfAcTime列表", notes = "查询XfAcTime列表")
    @RequestMapping(value = "/selectListByEntity", method = RequestMethod.POST)
    public JsonResult<List<XfAcTimeEntity>> selectListByEntity(@RequestBody XfAcTimeEntity record) {
                List<XfAcTimeEntity> list = xfAcTimeService.selectListByEntity(record);
                return succMsgData(list);
    }
	
		@Logs
	@ApiOperation(value = "删除XfAcTime信息", notes = "删除XfAcTime信息")
	@RequestMapping(value = "/deleteByPrimaryKey", method = RequestMethod.DELETE)
	public JsonResult<Object> deleteByPrimaryKey(@RequestParam Integer xh) {
        xfAcTimeService.deleteByPrimaryKey(xh);
        return succMsg();
	}

	@Logs
	@ApiOperation(value = "查询XfAcTime信息", notes = "查询XfAcTime信息")
	@RequestMapping(value = "/selectByPrimaryKey", method = RequestMethod.GET)
	public JsonResult<XfAcTimeEntity> selectByPrimaryKey(@RequestParam Integer xh) {
		XfAcTimeEntity entity = xfAcTimeService.selectByPrimaryKey(xh);
                return succMsgData(entity);
	}
	

		@Logs
	@ApiOperation(value = "批量删除XfAcTime信息", notes = "批量删除XfAcTime信息")
	@RequestMapping(value = "/deleteBatchByKeys", method = RequestMethod.POST)
	public JsonResult<Object> deleteBatchByKeys(@RequestBody List<XfAcTimeEntity> list) {
        List<XfAcTimeEntity> delList = new ArrayList<>();
        for (int i = 0; i < list.size(); i++) {
            delList.add(list.get(i));
            if (delList.size() == 20 || i == list.size() - 1) {
                xfAcTimeService.deleteBatchByKeys(delList);
                delList.clear();
            }
        }
		return succMsg();
	}
	
		@Logs
	@ApiOperation(value = "批量新增XfAcTime信息", notes = "批量新增XfAcTime信息")
	@RequestMapping(value = "/insertBatch", method = RequestMethod.PUT)
	public JsonResult<Object> insertBatch(@RequestParam String data) {
		List<XfAcTimeEntity> list	= JSONObject.parseArray(data, XfAcTimeEntity.class);
		xfAcTimeService.insertBatch(list);
		return succMsg();
	}
	}